package com.model.defaults.tabsheet;

import java.util.Map;

import org.hibernate.Session;

import com.core.GlobalConstants;
import com.model.ActionScript;
import com.model.KeyValue;
import com.model.TabSheetItem;
import com.model.UserContextName;



public class ModelDefaultTabsheetTask {

    public static void createTabsheetItemsTaskOpen ( Session session,
                                                     Map <String, UserContextName> userContexts ) {

        /*
         * OpenProject
         */

        TabSheetItem pojo = null;
        UserContextName contextName_1 = null;

        ActionScript actionScript = null;
        KeyValue actionScriptParam = null;

        /*
         * OpenTask
         */



        actionScript = new ActionScript();

        actionScriptParam = new KeyValue("t1", "selectedTab=1");
        session.save(actionScriptParam);
        actionScript.getParams().add(actionScriptParam);

        actionScriptParam = new KeyValue("p1", "?");
        actionScriptParam.setUserInfo(GlobalConstants.ACTIONSCRIPT_USERINFO_PARAM_KEY);
        session.save(actionScriptParam);
        actionScript.getParams().add(actionScriptParam);

        actionScript.setActionScriptType("servlet");
        actionScript.setActionScriptText("%s?{p1}&{t1}", GlobalConstants.SERVLET_TASKINFO);
        session.save(actionScript);

        contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_TASKAINFO);
        pojo = new TabSheetItem();
        pojo.setName("OpenTask.Description");
        pojo.setCaption("Description");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setJspNameInContext("details/ProjectTaskDescription.jsp");
        pojo.setServletNameToExecute(GlobalConstants.SERVLET_TASKINFO);
        pojo.setIsDefault(true);
        pojo.setActionScript(actionScript);
        session.save(pojo);


        actionScript = new ActionScript();

        actionScriptParam = new KeyValue("t1", "selectedTab=2");
        session.save(actionScriptParam);
        actionScript.getParams().add(actionScriptParam);

        actionScriptParam = new KeyValue("p1", "?");
        actionScriptParam.setUserInfo(GlobalConstants.ACTIONSCRIPT_USERINFO_PARAM_KEY);
        session.save(actionScriptParam);
        actionScript.getParams().add(actionScriptParam);

        actionScript.setActionScriptType("servlet");
        actionScript.setActionScriptText("%s?{p1}&{t1}", GlobalConstants.SERVLET_TASKINFO);
        session.save(actionScript);

        contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_TASKAINFO);
        pojo = new TabSheetItem();
        pojo.setName("OpenTask.Issues");
        pojo.setCaption("Issues");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setJspNameInContext("details/tabTaskTaskList.jsp");
        pojo.setServletNameToExecute(GlobalConstants.SERVLET_TASKINFO);
        pojo.setActionScript(actionScript);
        session.save(pojo);

        /*
         * ProjectOpen
         */
        contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_TASKAINFO);
        pojo = new TabSheetItem();
        pojo.setName("TaskComments");
        pojo.setCaption("Comments");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setJspNameInContext("details/ProjectTaskComments.jsp");
        pojo.setServletNameToExecute("TaskAddComment");
        session.save(pojo);

        contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_TASKAINFO);
        pojo = new TabSheetItem();
        pojo.setName("TaskHistory");
        pojo.setCaption("History");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setJspNameInContext("details/TaskHistory.jsp");
        pojo.setServletNameToExecute("TaskAddHistory");
        session.save(pojo);

        contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_TASKAINFO);
        pojo = new TabSheetItem();
        pojo.setName("TaskWorkLog");
        pojo.setCaption("Work log");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setJspNameInContext("details/ProjectTaskWorkLog.jsp");
        pojo.setServletNameToExecute("TaskAddWorkLog");
        session.save(pojo);

        contextName_1 = userContexts.get(GlobalConstants.USERCONTEXT_TASKAINFO);
        pojo = new TabSheetItem();
        pojo.setName("TaskSubtasks");
        pojo.setCaption("Subtasks");
        pojo.getUserContextNameVisibleIn().add(contextName_1);
        pojo.setJspNameInContext("details/ProjectTaskSubtasks.jsp");
        pojo.setServletNameToExecute("TaskAddSubtask");
        session.save(pojo);
    }


}
